;(function($) {

        $.fn.widgetContainer = function(){};
        $.fn.widgetContainer.addItem = function(options){
            var options = $.extend({}, $.fn.widgetContainer.defaults, options || {});

            if(options.id == undefined || options.item == undefined)
                return;

        var item = $.fn.widgetContainer.GetItems(options.item);
        
        if($('div#'+options.id+'>div#'+item.id).length<=0) {
            var items = '<div id="'+item.id+'" class="ui-state-highlight ui-corner-all item"><input id="'+item.id+'_items" name="'+options.id+'_items[]" type="hidden" value="'+item.id+'" /><a href="#" class="ui-state-default control" onClick="$(this).parent(\'div\').remove()"><span class="ui-icon ui-icon-circle-close"></span></a>'+item.value+'</div>';
            $('div#'+options.id).append(items);
        }
        $('div#'+options.id+' > div#'+item.id).hover(
		function() { $(this).children('a').show(); },
		function() { $(this).children('a').hide(); }
	);
        $('div#'+options.id+' > div#'+item.id+' > a').hover(
		function() { $(this).addClass('ui-state-hover'); },
		function() { $(this).removeClass('ui-state-hover'); }
	);
        };

        $.fn.widgetContainer.defaults = {
		label: '',
                itemid:''
	};

        $.fn.widgetContainer.AllItem = function(ID,SearchType) {
            
            $('body').append('<form id="Container_widget_form" style="visibility:hidden;"></form>');
            $('#Container_widget_form').html($('div#'+ID).clone());
            var data = $('#Container_widget_form').serialize();
            $('#Container_widget_form').remove();

            if(SearchType != '' && SearchType != undefined)
                data = data.toString().replaceAll(ID+"_items%5B%5D", SearchType+"[]");
            return data;
        };
        
        $.fn.widgetContainer.GetItems = function (item) {
            var strbuff = item.split(';');
            return {id:strbuff[0],value:strbuff[1]};
        };

})(jQuery);